# Compatibility
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
#IF PASCAL EXISTS
EXECUTE_PROCESS(COMMAND fpc -h RESULT_VARIABLE RESULT OUTPUT_VARIABLE OUT)
IF (NOT RESULT)

	# Project name
	PROJECT (pascal)

	ENABLE_TESTING()

    INCLUDE("${ROOT_DIR}/test/lib/test.cmake" OPTIONAL RESULT_VARIABLE TESTING_ENABLED)

	FILE (GLOB SOURCE test.pas)

	EXECUTE_PROCESS(COMMAND fpc ${SOURCE} RESULT_VARIABLE RESULT OUTPUT_VARIABLE OUTPUT)
	STRING(REGEX REPLACE ".*Linking (.+)[\t\n\r]+(.+) compiled.*$" "\\1" PROGRAM_TO_TEST "${OUTPUT}")
	STRING(REPLACE "\\" "/" PROGRAM_TO_TEST ${PROGRAM_TO_TEST})
    IF (NOT ("${TESTING_ENABLED}"STREQUAL NOTFOUND))
        CREATE_TESTS()
    ENDIF()
ENDIF()